package com.spark.lola.mapper.sup;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spark.lola.entity.sup.SupplierInfo;
import com.spark.lola.support.mybatis.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author dengyejun
 * @since 2020-04-24
 */
@Mapper
public interface SupplierInfoMapper extends BaseMapper<SupplierInfo> {
    IPage<SupplierInfo> page(Page page, @Param(Constants.WRAPPER) Wrapper wrapper);

    Integer updateSales(@Param("sales")BigDecimal sales,@Param("weight") BigDecimal weight,@Param("id")Long id);

    @Select("select IFNULL(remind_count,0) remind_count from sup_supplier_info where id=#{id}")
    int findRemindCount(long id);

    @Update("update sup_supplier_info set remind_count=#{remindCount} where id=#{id}")
    int updateRemindCount(int remindCount, long id);

    Integer updateOrderPayment(@Param("id")Long id,@Param("orderPayment")BigDecimal orderPayment);

    int resetSalesman(@Param("id")Long id);

    int resetService(@Param("id")Long id);

    int checkName(String name, Long id);

    int countSupervisor(String type, Long shiroId);

    @Select("select salesman_id,service_id,update_time from sup_supplier_info where used='Y'")
    List<SupplierInfo> findUsed();
}
